package com.movitech.mobile.ddzy.modules.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.concurrent.*;

import com.movitech.mobile.cz.base.common.sms.SmsUtil;
import com.movitech.mobile.cz.base.common.util.StringUtils;
import com.movitech.mobile.ddzy.sms.MgSmsServiceSoapBindingStub;
import com.movitech.mobile.ddzy.sms.SmsServiceServiceLocator;

@Service("extSmsUtil")
public class ExtSmsUtil extends SmsUtil {

	@Value("${mbs.mgsms.service.address.url}")
	private String mbsMgSmsServiceAddressUrl;

	@Value("${mbs.mgsms.bizlevel}")
	private String mbsMgSmsBizLevel;

	@Override
	public boolean sendSms(String phone, String smsContent) {
		boolean isSuccess = false;
		System.out.println("===========smsUtil-->sendSms2");
		try {
			SmsServiceServiceLocator smsServiceServiceLocator = new SmsServiceServiceLocator();
			smsServiceServiceLocator.setMgSmsServiceEndpointAddress(mbsMgSmsServiceAddressUrl);
			MgSmsServiceSoapBindingStub binding = (MgSmsServiceSoapBindingStub) smsServiceServiceLocator.getMgSmsService();
			String result = binding.sendSms(mbsMgSmsBizLevel, phone, smsContent);
			System.out.println(result);
			if(StringUtils.equalsIgnoreCase(result, "success")){
				isSuccess = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return isSuccess;
	}
}
